package cn.kgc.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author YC
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName(value = "menus")
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public class Menus extends Model<Menus> implements Serializable {

    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Integer id;


    /**
     * 菜单名称
     */
    @TableField(value = "menu_name")
    private String menuName;


    /**
     * 1菜单 2按钮
     */
    @TableField(value = "menu_type")
    private Integer menuType;


    /**
     * 菜单编码
     */
    @TableField(value = "menu_code")
    private String menuCode;


    /**
     * 组件
     */
    @TableField(value = "component")
    private String component;


    /**
     * 路由地址
     */
    @TableField(value = "path")
    private String path;


    /**
     * 图标
     */
    @TableField(value = "icon")
    private String icon;


    /**
     * 权限标识符
     */
    @TableField(value = "perm")
    private String perm;


    /**
     * 父菜单ID
     */
    @TableField(value = "parent_id")
    private Integer parentId;


    @TableField(value = "redirect")
    private String redirect;


    /**
     * 创建时间
     */
    @TableField(value = "creationDate", fill = FieldFill.INSERT)
    @JsonIgnore
    private Date creationDate;

    /**
     * 乐观锁
     */
    @Version
    @TableField(value = "version", fill = FieldFill.INSERT)
    private int version;

    /**
     * 菜单下的子菜单集合
     */
    @TableField(exist = false)
    private List<Menus> children = new ArrayList<>();


}
